예제 #1
0
 @Override
 public String trace() {
   String s = "";
   for (int i = 0; i < functions.size(); i++) {
     s += functions.getValue(i).trace();
   }
   return s;
 }
예제 #2
0
 @Override
 public void compile() {
   Debugger debugContext = DinaCompiler.getDebugger();
   int variablesWithValue = 0;
   int variablesAmount = getVariablesAmount();
   for (int variableIndex = 0; variableIndex < variablesAmount; variableIndex++) {
     Variable variable = getVariable(variableIndex);
     if (variable.getValue() != null) {
       if (constructor == null) {
         constructor = new Function(ParserConstants.CONSTRUCTOR);
         constructor.setStatement(new Block());
         constructor.getStatement().setFunction(constructor);
       }
       Assignment assignment = new Assignment(variable, variable.getValue());
       constructor.getStatement().insertNode(assignment, variablesWithValue);
       variablesWithValue++;
     }
   }
   if (constructor != null) {
     Output.writeSystemInformation(Constants.BEGIN_FUNCTION);
     constructor.compile();
     if (Debugger.DEVELOPMENT_MODE) {
       debugContext.putFunction("<constructor>", constructor.getAddress());
     }
     Output.writeSystemInformation(Constants.END_FUNCTION);
   }
   int functionsAmount = functions.size();
   for (int functionIndex = 0; functionIndex < functionsAmount; functionIndex++) {
     Function function = functions.getValue(functionIndex);
     Output.writeSystemInformation(Constants.BEGIN_FUNCTION);
     function.compile();
     if (Debugger.DEVELOPMENT_MODE) {
       debugContext.putFunction(
           function.getSignatureLabel() + function.getNodeType().getSignature(),
           function.getAddress());
     }
     Output.writeSystemInformation(Constants.END_FUNCTION);
   }
   if (destructor != null) {
     Output.writeSystemInformation(Constants.BEGIN_FUNCTION);
     destructor.compile();
     if (Debugger.DEVELOPMENT_MODE) {
       debugContext.putFunction("<destructor>", destructor.getAddress());
     }
     Output.writeSystemInformation(Constants.END_FUNCTION);
   }
 }
예제 #3
0
 public int getFunctionsAmount() {
   int value = functions.size();
   value += constructor == null ? 0 : 1;
   value += destructor == null ? 0 : 1;
   return value;
 }