public override void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) { symbol.CompileGet(compiler); expression.Compile(compiler); compiler.Binary.WriteSHR(); symbol.CompileSet(compiler); }
public sunConstantSymbol(string name, sunExpression expression) : base(name) { if (expression == null) { throw new ArgumentNullException("expression"); } mExpression = expression; }
public sunConstantSymbol DeclareConstant(string name, sunExpression expression) { if (GetIsDeclared(name)) { return(null); } var symbol = new sunConstantSymbol(name, expression); mStorables.Add(symbol); return(symbol); }
sunConstantSymbol DeclareConstant(sunIdentifier node, sunExpression expression, sunSymbolModifiers modifiers) { var local = (modifiers & sunSymbolModifiers.Local) != 0; var name = MangleSymbolName(node.Value, node.Location.ScriptId, false, local); var symbol = Scopes.DeclareConstant(name, expression); if (symbol == null) { throw new sunRedeclaredVariableException(node); } return(symbol); }
static sunExpressionFlags AnalyzeExpression(sunContext context, sunExpression expression) { var flags = sunExpressionFlags.None; foreach (var operand in expression.OfType <sunOperand>()) { var term = operand.Term as sunTerm; if (term != null) { flags |= term.GetExpressionFlags(context); } } return(flags); }
static void CompileExpression(sunCompiler compiler, sunExpression expression, Stack <sunOperator> operatorStack) { var stackCount = operatorStack.Count; foreach (var node in expression) { if (node is sunOperand) { var operand = node as sunOperand; // term var term = operand.Term; if (term is sunExpression) { CompileExpression(compiler, term as sunExpression, operatorStack); } else { term.Compile(compiler); } var unaryOperators = operand.UnaryOperators; if (unaryOperators != null) { unaryOperators.Compile(compiler); } } else if (node is sunOperator) { var operatorNode = node as sunOperator; while (operatorStack.Count > stackCount && (operatorNode.IsLeftAssociative && operatorNode.Precedence <= operatorStack.Peek().Precedence) || (operatorNode.IsRightAssociative && operatorNode.Precedence < operatorStack.Peek().Precedence)) { operatorStack.Pop().Compile(compiler); } operatorStack.Push(operatorNode); } } while (operatorStack.Count > stackCount) { operatorStack.Pop().Compile(compiler); } }
public sunConstantSymbol DeclareConstant(string name, sunExpression expression) { return(Top.DeclareConstant(name, expression)); }
public virtual void Compile(sunCompiler compiler, sunStorableSymbol symbol, sunExpression expression) { expression.Compile(compiler); symbol.CompileSet(compiler); }