public IfStatementNode(ExpressionNode condition, StatementNode thenBody, StatementNode elseBody) { Condition = condition; ThenBody = thenBody; ElseBody = elseBody; }
public WhileStatementNode(ExpressionNode condition, StatementNode body) { Condition = condition; Body = body; }
protected PredefinedSymFunc(string name, List <SymVar> parameters, SymTable localVariables, StatementNode body, SymType returnType) : base(name, parameters, localVariables, body, returnType) { }
public SymFunc(string name, List <SymVar> parameters, SymTable localVariables, StatementNode body, SymType returnType) { Name = name; Parameters = parameters; LocalVariables = localVariables; Body = body; if (returnType == null) { ReturnType = new SymVoid(); } else { ReturnType = returnType; } //predefined if (localVariables == null) { return; } foreach (var localSymbol in LocalVariables.Reverse()) { var lvar = localSymbol as SymVar; Debug.Assert(lvar != null); if (lvar.LocType != SymVar.SymLocTypeEnum.Local) { continue; } LocalVariableBsize += lvar.Type.BSize; LocalVarOffsetTable.Add(lvar.Name, LocalVariableBsize); } // align LocalVariableBsize += LocalVariableBsize % 8 > 0 ? 8 - LocalVariableBsize % 8 : 0; var paramOffset = 16; foreach (var param in parameters) { ParamsOffsetTable.Add(param.Name, paramOffset); var paramSize = param.Type.BSize; // parameters will be aligned on stack paramSize += paramSize % 8 > 0 ? 8 - paramSize % 8 : 0; paramOffset += paramSize; } ParamsSizeB = paramOffset; }
public void AddFunction(IdentifierToken nameToken, List <SymVar> paramList, SymTable localVars, StatementNode body, SymType returnType) { //todo: add checks RequireSymbolRewritable(nameToken); // SymType returnType = null; // if (returnTypeToken != null) { // returnType = FindType(returnTypeToken.Value); // if (returnType == null) // throw new TypeNotFoundException(returnTypeToken.Lexeme, returnTypeToken.Line, returnTypeToken.Column); // } // _stack.Peek().Add(new SymFunc(nameToken.Value, paramList, localVars, body, returnType)); AddConst(nameToken, new SymFuncConst(nameToken.Value, new SymFunc(nameToken.Value, paramList, localVars, body, returnType), SymVarOrConst.SymLocTypeEnum.Global)); }