Skip to content

Commit

Permalink
Reduce the duplicated code
Browse files Browse the repository at this point in the history
The grammar has been shorted removing duplicated or very similar elements
(for example method definitions are now function definitions).
By doing this, it gets simplier in all aspects since the code gets
centralized.
  • Loading branch information
Ruk33 committed Nov 16, 2015
1 parent f82b59a commit e47b6e2
Show file tree
Hide file tree
Showing 15 changed files with 571 additions and 576 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Collection;

import com.ruke.vrjassc.vrjassc.symbol.ClassSymbol;
import com.ruke.vrjassc.vrjassc.symbol.FunctionSymbol;
import com.ruke.vrjassc.vrjassc.symbol.MethodSymbol;
import com.ruke.vrjassc.vrjassc.symbol.Modifier;
Expand All @@ -25,7 +26,7 @@ public String translate() {

this.expressions.clear();

if (this.function instanceof MethodSymbol) {
if (this.function.getParentScope() instanceof ClassSymbol) {
if (!this.function.hasModifier(Modifier.STATIC)) {
this.add(new RawExpression("integer this"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.ruke.vrjassc.translator.expression;

import com.ruke.vrjassc.vrjassc.symbol.LocalVariableSymbol;
import com.ruke.vrjassc.vrjassc.symbol.Modifier;
import com.ruke.vrjassc.vrjassc.symbol.Symbol;
import com.ruke.vrjassc.vrjassc.symbol.Type;
import com.ruke.vrjassc.vrjassc.util.Prefix;
import com.ruke.vrjassc.vrjassc.util.VariableTypeDetector;

Expand Down Expand Up @@ -40,7 +40,7 @@ public String translate() {

String result = type + " " + name;

if (this.variable instanceof LocalVariableSymbol) {
if (this.variable.hasModifier(Modifier.LOCAL)) {
result = "local " + result;
}

Expand Down

0 comments on commit e47b6e2

Please sign in to comment.