public static FunctionCallNode CreateFunctionCall(AstNode call, params AstNode[] parameters) { List<AstNode> parameterList = new List<AstNode>(); foreach (var parameter in parameters) parameterList.Add(parameter); return new FunctionCallNode(ModuleBuilder.SourceLocation, call, new ArgumentListNode(ModuleBuilder.SourceLocation, parameterList), new List<BinaryOperationNode>()); }
public TernaryOperationNode(SourceLocation location, AstNode predicate, AstNode trueStatement, AstNode falseStatement) { this.SourceLocation = location; Children.Add(predicate); Children.Add(trueStatement); Children.Add(falseStatement); }
public SwitchNode(SourceLocation location, AstNode expression, List<Case> cases, AstNode defaultCase) { this.SourceLocation = location; Children.Add(expression); Children.Add(defaultCase); Cases = cases; }
public IfNode(SourceLocation location, AstNode predicate, AstNode body, AstNode elseBody) { this.SourceLocation = location; Children.Add(predicate); Children.Add(body); Children.Add(elseBody); }
public EnforcedAssignmentNode(SourceLocation location, string type, string variable, AstNode value) { this.SourceLocation = location; Type = type; Variable = variable; Children.Add(value); }
public ForeachNode(SourceLocation location, string variable, AstNode target, AstNode body) { this.SourceLocation = location; Variable = variable; Children.Add(target); Children.Add(body); }
public BinaryOperationNode(SourceLocation location, BinaryOperation operation, AstNode left, AstNode right) { this.SourceLocation = location; BinaryOperation = operation; Children.Add(left); Children.Add(right); }
public FunctionCallNode(SourceLocation location, AstNode target, ArgumentListNode parameters, List<BinaryOperationNode> initialAttributes) { this.SourceLocation = location; Children.Add(target); Children.Add(parameters); InitialAttributes = initialAttributes; }
public ForNode(SourceLocation location, AstNode startStatement, AstNode predicate, AstNode repeatStatement, AstNode body) { this.SourceLocation = location; Children.Add(startStatement); Children.Add(predicate); Children.Add(repeatStatement); Children.Add(body); }
public PropertyNode(SourceLocation location, string variable, AstNode getBody, AstNode setBody) { this.SourceLocation = location; Variable = variable; Children.Add(getBody); Children.Add(setBody); IsPrivate = false; }
public TryCatchNode(SourceLocation location, AstNode tryBody, AstNode catchBody) { this.SourceLocation = location; Children.Add(tryBody); Children.Add(catchBody); }
public SymbolTable Analyze(AstNode ast) { code = ast; result = new SymbolTable(); result.PushScope(); code.VisitChildren(this); return result; }
public Case(BinaryOperation operation, List<AstNode> expressions, AstNode body) { Operation = operation; Expressions = expressions; Body = body; }
public ThreadNode(SourceLocation location, bool runImmediately, AstNode body) { this.SourceLocation = location; RunImmediately = runImmediately; Children.Add(body); }
public HassiumModule Compile(AstNode ast, SymbolTable table) { this.table = table; module = new HassiumModule(); method = new HassiumMethod(); var globalParent = new HassiumClass(); foreach (AstNode child in ast.Children) { if (child is FuncNode) { compileFunc(child as FuncNode); method.Parent = new HassiumClass(); if (module.Attributes.ContainsKey(method.Name)) { if (module.Attributes[method.Name] is HassiumMultiFunc) ((HassiumMultiFunc)module.Attributes[method.Name]).Methods.Add(method); else if (module.Attributes[method.Name] is HassiumMethod) module.Attributes[method.Name] = new HassiumMultiFunc(new List<HassiumMethod>() { method, (HassiumMethod)module.Attributes[method.Name] }); } else module.Attributes.Add(method.Name, method); } else if (child is ClassNode) { var clazz = compileClass(child as ClassNode); clazz.Parent = globalParent; module.Attributes.Add(clazz.Name, clazz); } else if (child is ExpressionStatementNode) { if (child.Children[0] is BinaryOperationNode) { var binop = child.Children[0] as BinaryOperationNode; if (binop.BinaryOperation == BinaryOperation.Assignment) { string variable = ((IdentifierNode)binop.Left).Identifier; table.AddGlobalSymbol(variable); var temp = method; method = new HassiumMethod(); method.Name = variable; method.SourceRepresentation = string.Format("set_{0}", variable); binop.Right.Visit(this); method.Emit(child.SourceLocation, InstructionType.Return); module.InitialVariables.Add(table.GetGlobalSymbol(variable), method); method = temp; } } } else if (child is TraitNode || child is PropertyNode || child is UseNode || child is EnumNode) child.Visit(this); } preformInherits(module); return module; }
public AttributeAccessNode(SourceLocation location, AstNode left, string right) { this.SourceLocation = location; Children.Add(left); Right = right; }
public RaiseNode(SourceLocation location, AstNode expression) { this.SourceLocation = location; Children.Add(expression); }
public WhileNode(SourceLocation location, AstNode predicate, AstNode body) { this.SourceLocation = location; Children.Add(predicate); Children.Add(body); }
public static BinaryOperationNode CreateBinaryOperation(BinaryOperation operation, AstNode left, AstNode right) { return new BinaryOperationNode(ModuleBuilder.SourceLocation, operation, left, right); }
public void AddAstNode(AstNode ast) { FunctionBody.Children.Add(ast); }
public LambdaNode(SourceLocation location, ArgumentListNode parameters, AstNode body) { this.SourceLocation = location; Children.Add(parameters); Children.Add(body); }
public KeyValuePairNode(SourceLocation location, AstNode key, AstNode value) { this.SourceLocation = location; Children.Add(key); Children.Add(value); }
public ExpressionStatementNode(SourceLocation location, AstNode expression) { this.SourceLocation = location; Children.Add(expression); }
public UsingNode(SourceLocation location, AstNode body, AstNode expression) { this.SourceLocation = location; Children.Add(body); Children.Add(expression); }
public MultiAssignmentNode(List<AstNode> left, AstNode value) { Assignments = new List<BinaryOperationNode>(); foreach (var ast in left) Assignments.Add(new BinaryOperationNode(value.SourceLocation, BinaryOperation.Assignment, ast, value)); }
public GlobalNode(SourceLocation location, string variable, AstNode value) { this.SourceLocation = location; Variable = variable; Children.Add(value); }
public UnaryOperationNode(SourceLocation location, AstNode target, UnaryOperation unaryOperation) { this.SourceLocation = location; Children.Add(target); UnaryOperation = unaryOperation; }
public ReturnNode(SourceLocation location, AstNode value) { Children.Add(value); }
public ListAccessNode(SourceLocation location, AstNode target, AstNode element) { this.SourceLocation = location; Children.Add(target); Children.Add(element); }