AS3 direct editation - const/var primitive initialization fix, preincrement fix, type calling fix, unbounded attribute fix

This commit is contained in:
Jindra Pet��k
2014-04-21 08:02:49 +02:00
parent 6f5d96462a
commit 078c10c595
6 changed files with 28 additions and 15 deletions
@@ -1196,9 +1196,12 @@ public class AVM2SourceGenerator implements SourceGenerator {
sinitcode.add(ins(new InitPropertyIns(), traitName(si.getNamespace(), si.var)));
}
if (!si.isStatic() && si.value!=null) {
initcode.add(ins(new GetLocal0Ins()));
initcode.addAll(toInsList(si.value.toSource(localData, this)));
initcode.add(ins(new InitPropertyIns(), traitName(si.getNamespace(), si.var)));
//do not init basic values, that can be stored in trait
if(!(si.value instanceof IntegerValueAVM2Item) && !(si.value instanceof StringAVM2Item) && !(si.value instanceof BooleanAVM2Item) && !(si.value instanceof NullAVM2Item) && !(si.value instanceof UndefinedAVM2Item)){
initcode.add(ins(new GetLocal0Ins()));
initcode.addAll(toInsList(si.value.toSource(localData, this)));
initcode.add(ins(new InitPropertyIns(), traitName(si.getNamespace(), si.var)));
}
}
}
}
@@ -738,6 +738,8 @@ public class ActionScriptParser {
if (s.type == SymbolType.COLON) {
type = type(new Reference<Boolean>(false), importedClasses, openedNamespaces, new ArrayList<AssignableAVM2Item>());
s = lex();
}else{
type = TypeItem.UNBOUNDED;
}
GraphTargetItem value = null;
@@ -1870,10 +1872,10 @@ public class ActionScriptParser {
case MINUS:
s = lex();
if (s.isType(SymbolType.DOUBLE)) {
ret = new FloatValueAVM2Item(null, (Double) s.value);
ret = new FloatValueAVM2Item(null, -(Double) s.value);
existsRemainder = true;
} else if (s.isType(SymbolType.INTEGER)) {
ret = new IntegerValueAVM2Item(null, (Long) s.value);
ret = new IntegerValueAVM2Item(null, -(Long) s.value);
existsRemainder = true;
} else {
lexer.pushback(s);
@@ -97,14 +97,17 @@ public class CallAVM2Item extends AVM2Item {
callable = p;
}
int propIndex = -1;
if(callable instanceof TypeItem){
TypeItem t=(TypeItem)callable;
callable = new PropertyAVM2Item(null, t.fullTypeName, g.abc, g.allABCs, new ArrayList<Integer>(), new ArrayList<MethodBody>());
propIndex = AVM2SourceGenerator.resolveType(t, ((AVM2SourceGenerator)generator).abc);
}
Object obj = null;
if (callable instanceof PropertyAVM2Item) {
PropertyAVM2Item prop = (PropertyAVM2Item) callable;
Object obj = prop.object;
obj = prop.object;
if (obj == null) {
List<ABC> allAbcs = new ArrayList<>();
@@ -127,16 +130,21 @@ public class CallAVM2Item extends AVM2Item {
NameAVM2Item nobj = new NameAVM2Item(new TypeItem(localData.currentClass), 0, "this", null, false, new ArrayList<Integer>());
nobj.setRegNumber(0);
obj = nobj;
} else {
obj = new AVM2Instruction(0, new FindPropertyStrictIns(), new int[]{prop.resolveProperty(localData)}, new byte[0]);
}
propIndex = prop.resolveProperty(localData);
}
}
if(propIndex!=-1){
if(obj == null){
obj = new AVM2Instruction(0, new FindPropertyStrictIns(), new int[]{propIndex}, new byte[0]);
}
return toSourceMerge(localData, generator, obj, arguments,
new AVM2Instruction(0, new CallPropertyIns(), new int[]{prop.resolveProperty(localData), arguments.size()}, new byte[0])
ins(new CallPropertyIns(),propIndex,arguments.size())
);
}
throw new CompilationException("Cannot call a type", line);
//return new ArrayList<>();
throw new CompilationException("Not a callable", line);
}
@Override
@@ -106,7 +106,7 @@ public class IndexAVM2Item extends AssignableAVM2Item {
object,dupSetTemp(localData, generator, obj_temp),
index,dupSetTemp(localData, generator, index_temp),
ins(new GetPropertyIns(),indexPropIndex),
ins(new ConvertDIns()),
post?ins(new ConvertDIns()):null,
(!post)?(decrement?ins(new DecrementIns()):ins(new IncrementIns())):null,
needsReturn?ins(new DupIns()):null,
post?(decrement?ins(new DecrementIns()):ins(new IncrementIns())):null,
@@ -356,7 +356,7 @@ public class NameAVM2Item extends AssignableAVM2Item {
//Start get original
//generateGetLoc(regNumber), getTemp(localData, generator, index_temp),
ins(new GetPropertyIns(), g.abc.constants.getMultinameId(new Multiname(Multiname.MULTINAMEL, 0, 0, allNsSet(g.abc), 0, new ArrayList<Integer>()), true)),
!isInteger ? ins(new ConvertDIns()) : null,
(!isInteger && post) ? ins(new ConvertDIns()) : null,
//End get original
(!post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null,
needsReturn ? ins(new DupIns()) : null,
@@ -605,7 +605,7 @@ public class PropertyAVM2Item extends AssignableAVM2Item {
//getTemp(localData, generator, obj_temp),
//index!=null?getTemp(localData, generator, index_temp):null,
ins(new GetPropertyIns(), propertyId),
!isInteger ? ins(new ConvertDIns()) : null,
(!isInteger && post) ? ins(new ConvertDIns()) : null,
//End get original
(!post) ? (decrement ? ins(isInteger ? new DecrementIIns() : new DecrementIns()) : ins(isInteger ? new IncrementIIns() : new IncrementIns())) : null,
needsReturn ? ins(new DupIns()) : null,