Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/org/ooc/backend/cdirty/VariableDeclWriter.java b/src/org/ooc/backend/cdirty/VariableDeclWriter.java
- index e3034f2..fa5208e 100644
- --- a/src/org/ooc/backend/cdirty/VariableDeclWriter.java
- +++ b/src/org/ooc/backend/cdirty/VariableDeclWriter.java
- @@ -15,6 +15,26 @@ public class VariableDeclWriter {
- if(variableDecl.isExtern()) return false;
- + if (variableDecl.isGlobal())
- + {
- + assert cgen.current == cgen.hw;
- + cgen.current.app("extern ");
- + writeGuts(variableDecl, cgen);
- + cgen.current = cgen.cw;
- + writeGuts(variableDecl, cgen);
- + cgen.current.app(";\n");
- + cgen.current = cgen.hw;
- + }
- + else
- + {
- + writeGuts(variableDecl, cgen);
- + }
- +
- + return true;
- +
- + }
- +
- + private static void writeGuts(VariableDecl variableDecl, CGenerator cgen) throws IOException {
- // FIXME add const checking from the ooc side of things. Disabled C's
- // const keyword because it causes problems with class initializations
- //if(variableDecl.isConst()) cgen.current.app("const ");
- @@ -61,9 +81,6 @@ public class VariableDeclWriter {
- }
- }
- -
- - return true;
- -
- }
- private static void writeInitAndComma(CGenerator cgen, Type type,
- diff --git a/src/org/ooc/frontend/model/VariableDecl.java b/src/org/ooc/frontend/model/VariableDecl.java
- index 4be4505..35e39eb 100644
- --- a/src/org/ooc/frontend/model/VariableDecl.java
- +++ b/src/org/ooc/frontend/model/VariableDecl.java
- @@ -68,6 +68,7 @@ public class VariableDecl extends Declaration implements MustBeUnwrapped, Potent
- }
- private boolean isStatic;
- + private boolean isGlobal;
- protected Type type;
- protected TypeDecl typeDecl;
- @@ -146,6 +147,14 @@ public class VariableDecl extends Declaration implements MustBeUnwrapped, Potent
- this.isStatic = isStatic;
- }
- + public boolean isGlobal() {
- + return isGlobal;
- + }
- +
- + public void setGlobal(boolean isGlobal) {
- + this.isGlobal = isGlobal;
- + }
- +
- public void accept(Visitor visitor) throws IOException {
- visitor.visit(this);
- }
- diff --git a/src/org/ooc/frontend/parser/ModuleParser.java b/src/org/ooc/frontend/parser/ModuleParser.java
- index e8f9d4a..aa21312 100644
- --- a/src/org/ooc/frontend/parser/ModuleParser.java
- +++ b/src/org/ooc/frontend/parser/ModuleParser.java
- @@ -70,6 +70,7 @@ public class ModuleParser {
- if(declaration != null) {
- if(declaration instanceof VariableDecl) {
- module.getBody().add(new Line(declaration));
- + ((VariableDecl)declaration).setGlobal(true);
- } else {
- module.getBody().add(declaration);
- }
Add Comment
Please, Sign In to add comment