Fix coding style

This commit is contained in:
Yaski
2013-01-17 22:45:43 +06:00
parent 8e7d834a22
commit 64e7463d00
6 changed files with 1640 additions and 1644 deletions

View File

@@ -6,7 +6,7 @@
* It is desirable to notify that Covered Software was "Powered by AlternativaPlatform" with link to http://www.alternativaplatform.com/
* */
package alternativa.engine3d.materials.compiler {
import flash.utils.Dictionary;
/**
* @private
@@ -101,7 +101,7 @@ package alternativa.engine3d.materials.compiler {
// set if not equal
public static const SNE : uint = 0x2d;
public static const COMMAND_NAMES : Dictionary = new Dictionary();
public static const COMMAND_NAMES : Array = [];
COMMAND_NAMES[MOV] = "mov";
COMMAND_NAMES[ADD] = "add";
COMMAND_NAMES[SUB] = "sub";

View File

@@ -40,26 +40,26 @@ package alternativa.engine3d.materials.compiler {
switch(strType){
case "t":
lowerCode |= 0x2000000;
type = 2;
type = VariableType.TEMPORARY;
break;
case "o":
lowerCode |= 0x3000000;
type = 3;
type = VariableType.OUTPUT;
break;
case "v":
lowerCode |= 0x4000000;
type = 4;
type = VariableType.VARYING;
break;
case "d":
lowerCode |= 0x6000000;
type = 6;
type = VariableType.DEPTH;
break;
case "i":
lowerCode |= 0x7000000;
type = 7;
type = VariableType.INPUT;
break;
default :
throw new ArgumentError("Wrong destination register type, must be \"t\" or \"o\" or \"v\", var = " + source);
throw new ArgumentError('Wrong destination register type, must be "t" or "o" or "v" or "d", var = ' + source);
break;
}
}

View File

@@ -51,7 +51,7 @@ package alternativa.engine3d.materials.compiler {
alternativa3d var _linkedVariables:Object;
// Dictionary of temporary variables at this linker. Key is a name of variable, value is a variable.
private var _localVariables:Object = new Object();
private var _localVariables:Object = {};
// Key - procedure, value - array of strings.
private var _inputParams:Dictionary = new Dictionary();
@@ -61,9 +61,9 @@ package alternativa.engine3d.materials.compiler {
// Counters of variables by types
private var _locals:Vector.<uint> = new Vector.<uint>(7, true);
private var samplers:Object = new Object();
private var samplers:Object = {};
private var _varyings:Object = new Object();
private var _varyings:Object = {};
/**
* Creates a new Linker instance.
@@ -81,8 +81,8 @@ package alternativa.engine3d.materials.compiler {
data = null;
_locals[0] = _locals[1] = _locals[2] = _locals[3] = _locals[4] = _locals[5] = _locals[6] = 0;
procedures.length = 0;
_varyings = new Object();
samplers = new Object();
_varyings = {};
samplers = {};
commandsCount = 0;
slotsCount = 0;
@@ -218,7 +218,7 @@ package alternativa.engine3d.materials.compiler {
if (data != null) return;
var v:Variable;
var variables:Object = _linkedVariables = new Object();
var variables:Object = _linkedVariables = {};
var p:Procedure;
var i:int, j:int;
var nv:Variable;
@@ -259,7 +259,8 @@ package alternativa.engine3d.materials.compiler {
for (j = 0; j < jLength; j++) {
v = vector[j];
if (v == null || v.name == null) continue;
if (v.name == null && i != 2 && i != 6 && i != 3 && i != 7) {
if (v.name == null && i != 2 && i != 3 && i != 6 && i != 7) {
// TODO: Never happens
throw new Error("Linkage error: Noname variable. Procedure = " + p.name + ", type = " + i.toString() + ", index = " + j.toString());
}
nv = variables[v.name] = new Variable();
@@ -291,7 +292,7 @@ package alternativa.engine3d.materials.compiler {
if (p.variablesUsages[7].length > j) {
var inParam:Variable = p.variablesUsages[7][j];
if (inParam == null) {
throw new Error("Input parameter set, but not exist in code. paramName = " + param + ", register = i" + j.toString());
throw new Error("Input parameter set, but not used in code. paramName = " + param + ", register = i" + j.toString());
}
if (v.index < 0) {
v.index = _locals[v.type];
@@ -302,7 +303,6 @@ package alternativa.engine3d.materials.compiler {
inParam = inParam.next;
}
}
}
}
if (output != null) {
@@ -316,7 +316,7 @@ package alternativa.engine3d.materials.compiler {
// Output variable
continue;
}
throw new Error("Output parameter have not declared. paramName = " + param);
throw new Error("Output parameter not declared. paramName = " + param);
}
if (v.index < 0) {
if (v.type != 2) {
@@ -340,7 +340,7 @@ package alternativa.engine3d.materials.compiler {
v = vars[j];
if (v == null) continue;
while (v != null) {
v.writeToByteArray(data, v.index + _locals[2], VariableType.TEMPORARY, offset);
v.writeToByteArray(data, _locals[2] + v.index, VariableType.TEMPORARY, offset);
v = v.next;
}
}

View File

@@ -6,6 +6,7 @@
* It is desirable to notify that Covered Software was "Powered by AlternativaPlatform" with link to http://www.alternativaplatform.com/
* */
package alternativa.engine3d.materials.compiler {
import alternativa.engine3d.alternativa3d;
import flash.display3D.Context3DProgramType;
@@ -221,9 +222,6 @@ package alternativa.engine3d.materials.compiler {
var operands:Array = source.match(agalParser);
// It is possible not use the input parameter. It is optimization of the linker
// Determine the size of constant
var opCode:String = operands[0];
var destination:DestinationVariable;
var source1:SourceVariable;
@@ -461,7 +459,6 @@ package alternativa.engine3d.materials.compiler {
break;
}
// Fill of byteCode of command
byteCode.writeUnsignedInt(type);
if (destination != null) {

View File

@@ -6,6 +6,7 @@
* It is desirable to notify that Covered Software was "Powered by AlternativaPlatform" with link to http://www.alternativaplatform.com/
* */
package alternativa.engine3d.materials.compiler {
import flash.utils.ByteArray;
/**
@@ -22,7 +23,7 @@ package alternativa.engine3d.materials.compiler {
}
public function SourceVariable(source:String) {
var strType : String = String(source.match(/[catsoivd]/g)[0]);
var strType:String = String(source.match(/[catsoiv]/g)[0]);
var regmask:uint;
@@ -74,11 +75,8 @@ package alternativa.engine3d.materials.compiler {
case "i":
type = VariableType.INPUT;
break;
case "d":
type = VariableType.DEPTH;
break;
default :
throw new ArgumentError('Wrong source register type, must be "a" or "c" or "t" or "o" or "v" or "i" or "d", var = ' + source);
throw new ArgumentError('Wrong source register type, must be "a" or "c" or "t" or "o" or "v" or "i", var = ' + source);
break;
}
upperCode = type;
@@ -99,5 +97,6 @@ package alternativa.engine3d.materials.compiler {
byteCode.position = position + offset + 4;
byteCode.writeByte(newType);
}
}
}