mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-06-11 13:02:14 +00:00
Constructor is not a variable
This commit is contained in:
@@ -669,7 +669,9 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
||||
} else {
|
||||
fname = s.value.toString();
|
||||
}
|
||||
traitVariables.add(new Variable(true, prefix + fname, fnamePos, isStatic));
|
||||
if (!fname.equals(classNameStr)) { //ignore constructor
|
||||
traitVariables.add(new Variable(true, prefix + fname, fnamePos, isStatic));
|
||||
}
|
||||
if (fname.equals(classNameStr)) { //constructor
|
||||
if (isStatic) {
|
||||
errors.add(new SimpleParseException("Constructor cannot be static", lexer.yyline(), s.position));
|
||||
@@ -951,7 +953,7 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
||||
}
|
||||
subNameStr = s.value.toString();
|
||||
int subNamePos = s.position;
|
||||
sinitVariables.add(new Variable(true, pkgName.addWithSuffix(subNameStr).toPrintableString(true), subNamePos));
|
||||
sinitVariables.add(new Type(true, pkgName.addWithSuffix(subNameStr).toPrintableString(true), subNamePos));
|
||||
s = lex();
|
||||
|
||||
if (s.type == SymbolType.NOT) {
|
||||
@@ -986,7 +988,7 @@ public class ActionScript3SimpleParser implements SimpleParser {
|
||||
Reference<Boolean> cinitNeedsActivation = new Reference<>(false);
|
||||
Reference<Boolean> iinitNeedsActivation = new Reference<>(false);
|
||||
List<VariableOrScope> classVariables = new ArrayList<>();
|
||||
classVariables.add(new Variable(true, "this", s.position));
|
||||
classVariables.add(new Variable(true, "this", s.position, false));
|
||||
|
||||
classTraits(errors, !inPackage, cinitNeedsActivation, importedClasses, subOpenedNamespaces, pkgName, subNameStr, isInterface, iinitNeedsActivation, abc, classVariables);
|
||||
|
||||
|
||||
@@ -227,9 +227,11 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
while (true) {
|
||||
boolean isStatic = false;
|
||||
s = lex();
|
||||
int staticPos = -1;
|
||||
while (s.isType(SymbolType.STATIC, SymbolType.PUBLIC, SymbolType.PRIVATE)) {
|
||||
if (s.type == SymbolType.STATIC) {
|
||||
isStatic = true;
|
||||
staticPos = s.position;
|
||||
}
|
||||
s = lex();
|
||||
}
|
||||
@@ -245,8 +247,18 @@ public class ActionScript2SimpleParser implements SimpleParser {
|
||||
|
||||
if (!expectedIdentifier(errors, s, lexer.yyline())) {
|
||||
break;
|
||||
}
|
||||
|
||||
String simpleClassName = className.contains(".") ? className.substring(className.lastIndexOf(".") + 1) : className;
|
||||
|
||||
if (!simpleClassName.equals(s.value.toString())) { //not constructor
|
||||
traitVariables.add(new Variable(true, isStatic ? className + "." + s.value.toString() : "this." + s.value.toString(), s.position, isStatic));
|
||||
} else {
|
||||
if (isStatic) {
|
||||
errors.add(new SimpleParseException("Constructor cannot be static", lexer.yyline(), staticPos));
|
||||
}
|
||||
}
|
||||
traitVariables.add(new Variable(true, isStatic ? className + "." + s.value.toString() : "this." + s.value.toString(), s.position, isStatic));
|
||||
|
||||
if (!isInterface) {
|
||||
variables.add(function(errors, !isInterface, isStatic ? className + "." + s.value.toString() : "this." + s.value.toString(), isStatic ? -1 : s.position, true, traitVariables, inTellTarget, hasEval, isStatic));
|
||||
}
|
||||
|
||||
@@ -23,6 +23,6 @@ package com.jpexs.decompiler.flash.simpleparser;
|
||||
public class Type extends Variable {
|
||||
|
||||
public Type(boolean definition, String name, int position) {
|
||||
super(definition, name, position);
|
||||
super(definition, name, position, true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user