mirror of
https://github.com/MapMakersAndProgrammers/Alternativa3D.git
synced 2025-10-26 01:49:07 -07:00
Fix coding style
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
* It is desirable to notify that Covered Software was "Powered by AlternativaPlatform" with link to http://www.alternativaplatform.com/
|
* It is desirable to notify that Covered Software was "Powered by AlternativaPlatform" with link to http://www.alternativaplatform.com/
|
||||||
* */
|
* */
|
||||||
package alternativa.engine3d.materials.compiler {
|
package alternativa.engine3d.materials.compiler {
|
||||||
import flash.utils.Dictionary;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -101,7 +101,7 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
// set if not equal
|
// set if not equal
|
||||||
public static const SNE : uint = 0x2d;
|
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[MOV] = "mov";
|
||||||
COMMAND_NAMES[ADD] = "add";
|
COMMAND_NAMES[ADD] = "add";
|
||||||
COMMAND_NAMES[SUB] = "sub";
|
COMMAND_NAMES[SUB] = "sub";
|
||||||
|
|||||||
@@ -40,26 +40,26 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
switch(strType){
|
switch(strType){
|
||||||
case "t":
|
case "t":
|
||||||
lowerCode |= 0x2000000;
|
lowerCode |= 0x2000000;
|
||||||
type = 2;
|
type = VariableType.TEMPORARY;
|
||||||
break;
|
break;
|
||||||
case "o":
|
case "o":
|
||||||
lowerCode |= 0x3000000;
|
lowerCode |= 0x3000000;
|
||||||
type = 3;
|
type = VariableType.OUTPUT;
|
||||||
break;
|
break;
|
||||||
case "v":
|
case "v":
|
||||||
lowerCode |= 0x4000000;
|
lowerCode |= 0x4000000;
|
||||||
type = 4;
|
type = VariableType.VARYING;
|
||||||
break;
|
break;
|
||||||
case "d":
|
case "d":
|
||||||
lowerCode |= 0x6000000;
|
lowerCode |= 0x6000000;
|
||||||
type = 6;
|
type = VariableType.DEPTH;
|
||||||
break;
|
break;
|
||||||
case "i":
|
case "i":
|
||||||
lowerCode |= 0x7000000;
|
lowerCode |= 0x7000000;
|
||||||
type = 7;
|
type = VariableType.INPUT;
|
||||||
break;
|
break;
|
||||||
default :
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
alternativa3d var _linkedVariables:Object;
|
alternativa3d var _linkedVariables:Object;
|
||||||
|
|
||||||
// Dictionary of temporary variables at this linker. Key is a name of variable, value is a variable.
|
// 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.
|
// Key - procedure, value - array of strings.
|
||||||
private var _inputParams:Dictionary = new Dictionary();
|
private var _inputParams:Dictionary = new Dictionary();
|
||||||
@@ -61,9 +61,9 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
// Counters of variables by types
|
// Counters of variables by types
|
||||||
private var _locals:Vector.<uint> = new Vector.<uint>(7, true);
|
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.
|
* Creates a new Linker instance.
|
||||||
@@ -81,8 +81,8 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
data = null;
|
data = null;
|
||||||
_locals[0] = _locals[1] = _locals[2] = _locals[3] = _locals[4] = _locals[5] = _locals[6] = 0;
|
_locals[0] = _locals[1] = _locals[2] = _locals[3] = _locals[4] = _locals[5] = _locals[6] = 0;
|
||||||
procedures.length = 0;
|
procedures.length = 0;
|
||||||
_varyings = new Object();
|
_varyings = {};
|
||||||
samplers = new Object();
|
samplers = {};
|
||||||
|
|
||||||
commandsCount = 0;
|
commandsCount = 0;
|
||||||
slotsCount = 0;
|
slotsCount = 0;
|
||||||
@@ -218,7 +218,7 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
if (data != null) return;
|
if (data != null) return;
|
||||||
|
|
||||||
var v:Variable;
|
var v:Variable;
|
||||||
var variables:Object = _linkedVariables = new Object();
|
var variables:Object = _linkedVariables = {};
|
||||||
var p:Procedure;
|
var p:Procedure;
|
||||||
var i:int, j:int;
|
var i:int, j:int;
|
||||||
var nv:Variable;
|
var nv:Variable;
|
||||||
@@ -259,7 +259,8 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
for (j = 0; j < jLength; j++) {
|
for (j = 0; j < jLength; j++) {
|
||||||
v = vector[j];
|
v = vector[j];
|
||||||
if (v == null || v.name == null) continue;
|
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());
|
throw new Error("Linkage error: Noname variable. Procedure = " + p.name + ", type = " + i.toString() + ", index = " + j.toString());
|
||||||
}
|
}
|
||||||
nv = variables[v.name] = new Variable();
|
nv = variables[v.name] = new Variable();
|
||||||
@@ -291,7 +292,7 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
if (p.variablesUsages[7].length > j) {
|
if (p.variablesUsages[7].length > j) {
|
||||||
var inParam:Variable = p.variablesUsages[7][j];
|
var inParam:Variable = p.variablesUsages[7][j];
|
||||||
if (inParam == null) {
|
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) {
|
if (v.index < 0) {
|
||||||
v.index = _locals[v.type];
|
v.index = _locals[v.type];
|
||||||
@@ -302,7 +303,6 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
inParam = inParam.next;
|
inParam = inParam.next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (output != null) {
|
if (output != null) {
|
||||||
@@ -316,7 +316,7 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
// Output variable
|
// Output variable
|
||||||
continue;
|
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.index < 0) {
|
||||||
if (v.type != 2) {
|
if (v.type != 2) {
|
||||||
@@ -340,7 +340,7 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
v = vars[j];
|
v = vars[j];
|
||||||
if (v == null) continue;
|
if (v == null) continue;
|
||||||
while (v != null) {
|
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;
|
v = v.next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
* It is desirable to notify that Covered Software was "Powered by AlternativaPlatform" with link to http://www.alternativaplatform.com/
|
* It is desirable to notify that Covered Software was "Powered by AlternativaPlatform" with link to http://www.alternativaplatform.com/
|
||||||
* */
|
* */
|
||||||
package alternativa.engine3d.materials.compiler {
|
package alternativa.engine3d.materials.compiler {
|
||||||
|
|
||||||
import alternativa.engine3d.alternativa3d;
|
import alternativa.engine3d.alternativa3d;
|
||||||
|
|
||||||
import flash.display3D.Context3DProgramType;
|
import flash.display3D.Context3DProgramType;
|
||||||
@@ -221,9 +222,6 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
|
|
||||||
var operands:Array = source.match(agalParser);
|
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 opCode:String = operands[0];
|
||||||
var destination:DestinationVariable;
|
var destination:DestinationVariable;
|
||||||
var source1:SourceVariable;
|
var source1:SourceVariable;
|
||||||
@@ -461,7 +459,6 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Fill of byteCode of command
|
// Fill of byteCode of command
|
||||||
byteCode.writeUnsignedInt(type);
|
byteCode.writeUnsignedInt(type);
|
||||||
if (destination != null) {
|
if (destination != null) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
* It is desirable to notify that Covered Software was "Powered by AlternativaPlatform" with link to http://www.alternativaplatform.com/
|
* It is desirable to notify that Covered Software was "Powered by AlternativaPlatform" with link to http://www.alternativaplatform.com/
|
||||||
* */
|
* */
|
||||||
package alternativa.engine3d.materials.compiler {
|
package alternativa.engine3d.materials.compiler {
|
||||||
|
|
||||||
import flash.utils.ByteArray;
|
import flash.utils.ByteArray;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -22,7 +23,7 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function SourceVariable(source:String) {
|
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;
|
var regmask:uint;
|
||||||
|
|
||||||
@@ -74,11 +75,8 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
case "i":
|
case "i":
|
||||||
type = VariableType.INPUT;
|
type = VariableType.INPUT;
|
||||||
break;
|
break;
|
||||||
case "d":
|
|
||||||
type = VariableType.DEPTH;
|
|
||||||
break;
|
|
||||||
default :
|
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;
|
break;
|
||||||
}
|
}
|
||||||
upperCode = type;
|
upperCode = type;
|
||||||
@@ -99,5 +97,6 @@ package alternativa.engine3d.materials.compiler {
|
|||||||
byteCode.position = position + offset + 4;
|
byteCode.position = position + offset + 4;
|
||||||
byteCode.writeByte(newType);
|
byteCode.writeByte(newType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user