Exemplo n.º 1
0
        public Finalizer(LexicalScope/*!*/ definedScope, Statements statements, SourceSpan location)
            : base(location) {
            Assert.NotNull(definedScope);

            _definedScope = definedScope;
            _statements = statements;
        }
Exemplo n.º 2
0
        public ModuleDefinition(LexicalScope/*!*/ definedScope, ConstantVariable/*!*/ qualifiedName, Body/*!*/ body, SourceSpan location)
            : base(definedScope, body, location)
        {
            ContractUtils.RequiresNotNull(qualifiedName, "qualifiedName");

            _qualifiedName = qualifiedName;
        }
Exemplo n.º 3
0
        public override bool ResolveNames(LexicalScope scope)
        {
            // Step 1: Create new scope and populate the symbol table
            var newScope = getNewScope(scope, null);

            // Step 1a: add all class declarations to the current scope
            foreach (Statement each in ClassDeclarations)
            {
                Declaration classDec = each as Declaration;
                if (classDec != null)
                {
                    classDec.AddItemsToSymbolTable(newScope);
                }
            }

            // Step 2: ResolveNames for each part of the complilation unit
            bool loopResolve = true;

            if (ClassDeclarations != null)
            {
                foreach (ClassDeclaration each in ClassDeclarations)
                {
                    loopResolve = loopResolve & each.ResolveNames(newScope);
                }
            }

            // need to do something special with package declarations and import declarations - Nathan

            return(loopResolve);
        }
Exemplo n.º 4
0
		public static LexicalScope getNewScope(LexicalScope oldScope, List<Expression> variableList)
		{
            // Step 1: Create scope that includes standard libraries (ie Java.Lang) if oldScope == null.
            if (oldScope == null)
            {
                var JLnode = new JavaLang();
                oldScope = new LexicalScope();
                oldScope.Symbol_table = new Dictionary<string, Declaration>();
                JLnode.AddItemsToSymbolTable(oldScope);
            }

			// Step 1: set the new scope
			var newScope = new LexicalScope();
			newScope.ParentScope = oldScope;
			newScope.Symbol_table = new Dictionary<string, Declaration>();

			// Step 2: Check for declarations in the new scope and add to symbol_table of old scope
			if (variableList != null)
			{
				foreach (Expression each in variableList)
				{
					Declaration decl = each as Declaration; // try to cast statement as a declaration
					if (decl != null)
					{
                        decl.AddItemsToSymbolTable(newScope);
					}
				}
			}

			return newScope;
		}
        private static void BuildScopesInFunctionParameters(
            LexicalScope containingScope,
            FunctionDeclarationSyntax function,
            ExpressionLexicalScopesBuilder binder)
        {
            if (function.GenericParameters != null)
            {
                foreach (var parameter in function.GenericParameters)
                {
                    binder.VisitExpression(parameter.TypeExpression, containingScope);
                }
            }

            foreach (var parameter in function.Parameters)
            {
                switch (parameter)
                {
                case NamedParameterSyntax namedParameter:
                    binder.VisitExpression(namedParameter.TypeExpression, containingScope);
                    break;

                case SelfParameterSyntax _:
                case FieldParameterSyntax _:
                    // Nothing to bind
                    break;

                default:
                    throw NonExhaustiveMatchException.For(parameter);
                }
            }
        }
Exemplo n.º 6
0
        public override bool ResolveNames(LexicalScope scope)
        {
            // Step 1: Create new scope and populate the symbol table
            // Special case with blocks - add to symbol table line by line as the names are resolved.
            // This is the catch the situation where the declaration is after the use of the variable.
            //var newScope = getNewScope(scope, null);

            // Step 2: ResolveNames for each part of the complilation unit
            bool loopResolve = true;

            if (statements != null)
            {
                foreach (Statement each in statements)
                {
                    Declaration decl = each as Declaration; // try to cast statement as a declaration
                    if (decl != null)
                    {
                        decl.AddItemsToSymbolTable(scope);
                    }
                    loopResolve = loopResolve & each.ResolveNames(scope);
                }
            }

            return(loopResolve);
        }
Exemplo n.º 7
0
        public ModuleDefinition(LexicalScope /*!*/ definedScope, ConstantVariable /*!*/ qualifiedName, Body /*!*/ body, SourceSpan location)
            : base(definedScope, body, location)
        {
            ContractUtils.RequiresNotNull(qualifiedName, "qualifiedName");

            _qualifiedName = qualifiedName;
        }
Exemplo n.º 8
0
 public ForLoopExpression(LexicalScope /*!*/ definedScope, CompoundLeftValue /*!*/ variables, Expression /*!*/ list, Statements body, SourceSpan location)
     : base(location)
 {
     Assert.NotNull(definedScope, variables, list);
     _block = new BlockDefinition(definedScope, variables, body, location);
     _list  = list;
 }
Exemplo n.º 9
0
        public Initializer(LexicalScope/*!*/ definedScope, List<Expression> statements, SourceSpan location)
            : base(location) {
            Assert.NotNull(definedScope);

            _definedScope = definedScope;
            _statements = statements;
        }
Exemplo n.º 10
0
        public SingletonDefinition(LexicalScope /*!*/ definedScope, Expression /*!*/ singleton, Body /*!*/ body, SourceSpan location)
            : base(definedScope, body, location)
        {
            ContractUtils.RequiresNotNull(singleton, "singleton");

            _singleton = singleton;
        }
Exemplo n.º 11
0
        public override bool ResolveNames(LexicalScope scope)
        {
            bool loopResolve = true;

            if (args != null)
            {
                foreach (Expression argument in args)
                {
                    loopResolve = loopResolve & argument.ResolveNames(scope);
                }
            }

            // check for valid declaration of method...
            if (scope != null)
            {
                declarationRef = scope.Resolve(name);
            }

            if (declarationRef == null)
            {
                Console.WriteLine("Error: Undeclared method indentifier", name);
                throw new Exception("Name Resolution Error - can not resolve method name");
            }

            return((declarationRef != null) & loopResolve);
        }
        private LexicalScope BuildNamespaceScopes(
            LexicalScope containingScope,
            RootName ns)
        {
            Name name;

            switch (ns)
            {
            case GlobalNamespaceName _:
                return(containingScope);

            case QualifiedName qualifiedName:
                containingScope = BuildNamespaceScopes(containingScope, qualifiedName.Qualifier);
                name            = qualifiedName;
                break;

            case SimpleName simpleName:
                name = simpleName;
                break;

            default:
                throw NonExhaustiveMatchException.For(ns);
            }

            var symbolsInNamespace       = allSymbols.Where(s => s.FullName.HasQualifier(name));
            var symbolsNestedInNamespace = allSymbols.Where(s => s.FullName.IsNestedIn(name));

            return(new NestedScope(containingScope, symbolsInNamespace, symbolsNestedInNamespace));
        }
Exemplo n.º 13
0
        public SingletonDefinition(LexicalScope/*!*/ definedScope, Expression/*!*/ singleton, Body/*!*/ body, SourceSpan location)
            : base(definedScope, body, location)
        {
            ContractUtils.RequiresNotNull(singleton, "singleton");

            _singleton = singleton;
        }
Exemplo n.º 14
0
        public ForLoopExpression(LexicalScope/*!*/ definedScope, Parameters/*!*/ variables, Expression/*!*/ list, Statements body, SourceSpan location)
            : base(location) {
            Assert.NotNull(definedScope, variables, list);

            _block = new BlockDefinition(definedScope, variables, body, location);
            _list = list;
        }
Exemplo n.º 15
0
        public ClassDefinition(LexicalScope/*!*/ definedScope, ConstantVariable/*!*/ name, Expression superClass, Body/*!*/ body, SourceSpan location)
            : base(definedScope, name, body, location)
        {
            ContractUtils.RequiresNotNull(name, "name");

            _superClass = superClass;
        }
Exemplo n.º 16
0
        public ClassDefinition(LexicalScope /*!*/ definedScope, ConstantVariable /*!*/ name, Expression superClass, Body /*!*/ body, SourceSpan location)
            : base(definedScope, name, body, location)
        {
            ContractUtils.RequiresNotNull(name, "name");

            _superClass = superClass;
        }
Exemplo n.º 17
0
        public void EnterMethodDefinition(
            ScopeBuilder /*!*/ locals,
            MSA.Expression /*!*/ selfParameter,
            MSA.ParameterExpression /*!*/ runtimeScopeVariable,
            MSA.Expression blockParameter,
            string /*!*/ methodName,
            Parameters parameters)
        {
            Assert.NotNull(locals, selfParameter, runtimeScopeVariable);

            MethodScope method = new MethodScope(
                locals,
                selfParameter,
                runtimeScopeVariable,
                blockParameter,
                methodName,
                parameters
                );

            method.Parent              = _currentElement;
            method.ParentRescue        = _currentRescue;
            method.ParentLoop          = _currentLoop;
            method.ParentBlock         = _currentBlock;
            method.ParentVariableScope = _currentVariableScope;
            method.ParentMethod        = _currentMethod;

            _currentElement       = method;
            _currentRescue        = null;
            _currentLoop          = null;
            _currentBlock         = null;
            _currentVariableScope = method;
            _currentMethod        = method;
        }
Exemplo n.º 18
0
        public FileInitializerStatement(LexicalScope /*!*/ definedScope, Statements /*!*/ statements, SourceSpan location)
            : base(location)
        {
            Assert.NotNull(definedScope);

            _definedScope = definedScope;
            _statements   = statements;
        }
Exemplo n.º 19
0
        public BlockDefinition(LexicalScope/*!*/ definedScope, CompoundLeftValue/*!*/ parameters, Statements/*!*/ body, SourceSpan location)
            : base(location) {
            Assert.NotNull(definedScope, parameters, body);

            _definedScope = definedScope;
            _body = body;
            _parameters = parameters;
        }
 public FunctionDeclarationStatementNode(LexicalScope scope, string name, ParameterNode[] parameters, ElementNode[] body, SourceSpan sourceSpan)
     : base(sourceSpan)
 {
     this.scope = scope;
     this.name = name;
     this.parameters = parameters;
     this.body = body;
 }
Exemplo n.º 21
0
        internal override Expression/*!*/ ToCondition(LexicalScope/*!*/ currentScope) {
            var newExpression = _expression.ToCondition(currentScope);
            if (newExpression != _expression) {
                return new NotExpression(newExpression, Location);
            }

            return this;
        }
Exemplo n.º 22
0
        public BlockDefinition(LexicalScope/*!*/ definedScope, Parameters parameters, Statements/*!*/ body, SourceSpan location)
            : base(location) {
            Assert.NotNull(definedScope, body);

            _definedScope = definedScope;
            _body = body;
            _parameters = parameters ?? Parameters.Empty; 
        }
Exemplo n.º 23
0
        public override bool ResolveNames(LexicalScope scope)
        {
            // 1. create new scope
            var newScope = getNewScope(scope, null);

            // 2. resolve names in while condition and statement(s)
            return(Cond.ResolveNames(newScope) & Statements.ResolveNames(newScope));
        }
Exemplo n.º 24
0
        public override bool ResolveNames(LexicalScope scope)
        {
            // Step 1: Add variables to symboltable
            AddItemsToSymbolTable(scope);

            // Step 2: ResolveName on variable type
            return(varType.ResolveNames(scope));
        }
Exemplo n.º 25
0
        public Finalizer(LexicalScope /*!*/ definedScope, List <Expression> statements, SourceSpan location)
            : base(location)
        {
            Assert.NotNull(definedScope);

            _definedScope = definedScope;
            _statements   = statements;
        }
Exemplo n.º 26
0
        public BlockDefinition(LexicalScope definedScope, CompoundLeftValue/*!*/ parameters, List<Expression>/*!*/ body, SourceSpan location)
            : base(location) {
            Assert.NotNull(parameters, body);

            _definedScope = definedScope;
            _body = body;
            _parameters = parameters;
        }
Exemplo n.º 27
0
        public void LeaveFileInitializer()
        {
            Debug.Assert(_currentElement == _currentVariableScope);
            VariableScope oldScope = _currentVariableScope;

            _currentElement       = oldScope.Parent;
            _currentVariableScope = oldScope.ParentVariableScope;
        }
Exemplo n.º 28
0
        protected DefinitionExpression(LexicalScope/*!*/ definedScope, Body/*!*/ body, SourceSpan location) 
            : base(location) {
            ContractUtils.RequiresNotNull(definedScope, "definedScope");
            ContractUtils.RequiresNotNull(body, "body");

            _definedScope = definedScope;
            _body = body;
        }
Exemplo n.º 29
0
        private void CompileLet(object form, LexicalScope lexScope)
        {
            throw new NotImplementedException();
              // Cons consForm = form as Cons;
              // if(consForm == null)
              // {
              //   throw new CompilerError("{0} is not let-form!", form);
              // }

              // Cons formArgs = consForm.Tail as Cons;
              // if(formArgs == null)
              // {
              //   throw new CompilerError("{0} is not let-form!", form);
              // }

              // Cons bindingList = formArgs.Head as Cons;
              // if(bindingList == null)
              // {
              //   throw new CompilerError("{0} is not let-form!", form);
              // }

              // while(bindingList != Cons.Nil)
              // {
              //   object arg = bindingList.Head;
              //   String type = TypeResolver.GetTypeRef(arg.GetType());
              //   switch(type)
              //   {
              //     case "symbol":
              //       lexScope.Bind(arg as Symbol, "value", Cons.Nil);
              //       break;

              //     case "cons":
              //       Cons argSpec = arg as Cons;
              //       Symbol sym = argSpec.Head as Symbol;
              //       if(sym == null)
              //       {
              //         throw new TypeError(argSpec.Head, typeof(Symbol));
              //       }
              //       Cons specTail = argSpec.Tail as Cons;
              //       if(specTail == null)
              //       {
              //         throw new TypeError(specTail.Tail, typeof(Cons));
              //       }
              //       object value = specTail.Head;
              //       lexScope.Bind(sym, "value", value);
              //       break;
              //     default:
              //       throw new TypeError(arg, typeof(Symbol));
              //   }

              //   Cons newArgs = bindingList.Tail as Cons;
              //   if(newArgs == null)
              //   {
              //     throw new TypeError(newArgs, typeof(Cons));
              //   }
              //   bindingList = newArgs;
              // }
        }
Exemplo n.º 30
0
        public BlockDefinition(LexicalScope definedScope, CompoundLeftValue /*!*/ parameters, List <Expression> /*!*/ body, SourceSpan location)
            : base(location)
        {
            Assert.NotNull(parameters, body);

            _definedScope = definedScope;
            _body         = body;
            _parameters   = parameters;
        }
Exemplo n.º 31
0
        public BlockDefinition(LexicalScope /*!*/ definedScope, CompoundLeftValue /*!*/ parameters, Statements /*!*/ body, SourceSpan location)
            : base(location)
        {
            Assert.NotNull(definedScope, parameters, body);

            _definedScope = definedScope;
            _body         = body;
            _parameters   = parameters;
        }
Exemplo n.º 32
0
        public MethodDefinition(LexicalScope/*!*/ definedScope, Expression target, string/*!*/ name, Parameters parameters, Body/*!*/ body, 
            SourceSpan location)
            : base(definedScope, body, location) {
            Assert.NotNull(name);

            _target = target;
            _name = name;
            _parameters = parameters ?? Parameters.Empty;
        }
Exemplo n.º 33
0
        public BlockDefinition(LexicalScope /*!*/ definedScope, Parameters parameters, Statements /*!*/ body, SourceSpan location)
            : base(location)
        {
            Assert.NotNull(definedScope, body);

            _definedScope = definedScope;
            _body         = body;
            _parameters   = parameters ?? Parameters.Empty;
        }
Exemplo n.º 34
0
        public void LeaveModuleDefinition()
        {
            Debug.Assert(_currentElement == _currentModule);
            ModuleScope oldModule = _currentModule;

            _currentElement       = oldModule.Parent;
            _currentVariableScope = oldModule.ParentVariableScope;
            _currentModule        = oldModule.ParentModule;
        }
Exemplo n.º 35
0
        protected DefinitionExpression(LexicalScope /*!*/ definedScope, Body /*!*/ body, SourceSpan location)
            : base(location)
        {
            ContractUtils.RequiresNotNull(definedScope, "definedScope");
            ContractUtils.RequiresNotNull(body, "body");

            _definedScope = definedScope;
            _body         = body;
        }
Exemplo n.º 36
0
 public ForStatementNode(LexicalScope scope, StatementNode initializer, ExpressionNode condition,
     ExpressionNode incrementer, StatementNode body, SourceSpan span)
     : base(span)
 {
     this.scope = scope;
     this.initializer = initializer;
     this.condition = condition;
     this.incrementer = incrementer;
     this.body = body;
 }
Exemplo n.º 37
0
        public MethodDefinition(LexicalScope /*!*/ definedScope, Expression target, string /*!*/ name, Parameters parameters, Body /*!*/ body,
                                SourceSpan location)
            : base(definedScope, body, location)
        {
            Assert.NotNull(name);

            _target     = target;
            _name       = name;
            _parameters = parameters ?? Parameters.Empty;
        }
Exemplo n.º 38
0
        internal override Expression/*!*/ ToCondition(LexicalScope/*!*/ currentScope) {
            var newLeft = _left.ToCondition(currentScope);
            var newRight = _right.ToCondition(currentScope);

            if (newLeft != _left || newRight != _right) {
                return new OrExpression(newLeft, newRight, Location);
            }

            return this;
        }
Exemplo n.º 39
0
        public void LeaveSourceUnit()
        {
            Debug.Assert(_currentElement == _currentMethod && _currentVariableScope == _currentMethod);
            Debug.Assert(_currentLoop == null && _currentRescue == null);
            Debug.Assert(_currentBlock == null);

            _currentElement       = null;
            _currentMethod        = null;
            _currentVariableScope = null;
        }
Exemplo n.º 40
0
 internal override Expression/*!*/ ToCondition(LexicalScope/*!*/ currentScope) {
     int intBegin, intEnd;
     if (!IsIntegerRange(out intBegin, out intEnd)) {
         return new RangeCondition(
             this,
             currentScope.GetInnerMostTopScope().AddVariable("#FlipFlopState" + Interlocked.Increment(ref _flipFlopVariableId), Location)
         );
     }
     return this;
 }
Exemplo n.º 41
0
        /// <summary>
        /// Gets the inner most scope that compiles to a lambda expression.
        /// </summary>
        private VariableScope /*!*/ GetCurrentLambdaScope()
        {
            LexicalScope scope = _currentVariableScope;

            while (!scope.IsLambda)
            {
                scope = scope.Parent;
            }
            return((VariableScope)scope);
        }
Exemplo n.º 42
0
        public ArgumentVariable(int index, string name, LexicalScope parentScope, IChelaType type)
            : base(type, parentScope.GetModule())
        {
            base.SetName(name);
            this.parentScope = parentScope;

            // Add the variable into the scope.
            this.index = index;
            parentScope.AddArgument(this);
        }
Exemplo n.º 43
0
        public ArgumentVariable(int index, string name, LexicalScope parentScope, IChelaType type)
            : base(type, parentScope.GetModule())
        {
            base.SetName(name);
            this.parentScope = parentScope;

            // Add the variable into the scope.
            this.index = index;
            parentScope.AddArgument(this);
        }
Exemplo n.º 44
0
        internal override Expression /*!*/ ToCondition(LexicalScope /*!*/ currentScope)
        {
            // propagates 'in condition' property if we have a single element:
            if (_statements != null && _statements.Count == 1 && !HasExceptionHandling)
            {
                return(_statements.First.ToCondition(currentScope));
            }

            return(this);
        }
Exemplo n.º 45
0
        public void EnterRescueClause(MSA.Expression /*!*/ retryingVariable, MSA.LabelTarget /*!*/ breakLabel, MSA.LabelTarget /*!*/ continueLabel)
        {
            Assert.NotNull(retryingVariable, breakLabel, continueLabel);

            RescueScope body = new RescueScope(retryingVariable, breakLabel, continueLabel);

            body.Parent       = _currentElement;
            body.ParentRescue = _currentRescue;

            _currentElement = _currentRescue = body;
        }
Exemplo n.º 46
0
        public void EnterLoop(MSA.Expression /*!*/ redoVariable, MSA.Expression /*!*/ resultVariable, MSA.LabelTarget /*!*/ breakLabel, MSA.LabelTarget /*!*/ continueLabel)
        {
            Assert.NotNull(redoVariable, resultVariable, breakLabel, continueLabel);

            LoopScope loop = new LoopScope(redoVariable, resultVariable, breakLabel, continueLabel);

            loop.Parent     = _currentElement;
            loop.ParentLoop = _currentLoop;

            _currentElement = _currentLoop = loop;
        }
Exemplo n.º 47
0
        internal override Expression /*!*/ ToCondition(LexicalScope /*!*/ currentScope)
        {
            var newExpression = _expression.ToCondition(currentScope);

            if (newExpression != _expression)
            {
                return(new NotExpression(newExpression, Location));
            }

            return(this);
        }
Exemplo n.º 48
0
        public void LeaveBlockDefinition()
        {
            Debug.Assert(_currentElement == _currentBlock);
            BlockScope oldBlock = _currentBlock;

            _currentElement       = oldBlock.Parent;
            _currentRescue        = oldBlock.ParentRescue;
            _currentLoop          = oldBlock.ParentLoop;
            _currentVariableScope = oldBlock.ParentVariableScope;
            _currentBlock         = oldBlock.ParentBlock;
        }
Exemplo n.º 49
0
        public MethodDefinition(LexicalScope/*!*/ definedScope, Expression target, string/*!*/ name, Parameters parameters, Body/*!*/ body, 
            SourceSpan location)
            : base(definedScope, body, location)
        {
            Assert.NotNull(name);

            // only for-loop block might use other than local variable for unsplat:
            Debug.Assert(parameters.Unsplat == null || parameters.Unsplat is LocalVariable);

            _target = target;
            _name = name;
            _parameters = parameters ?? Parameters.Empty;
        }
Exemplo n.º 50
0
        public ScopeBuilder(AstParameters parameters, int firstClosureParam, int localCount, 
            ScopeBuilder parent, LexicalScope/*!*/ lexicalScope) {
            Debug.Assert(parent == null || parent.LexicalScope == lexicalScope.OuterScope);
#if DEBUG
            _id = Interlocked.Increment(ref _Id);
#endif
            _parent = parent;
            _parameters = parameters;
            _localCount = localCount;
            _firstClosureParam = firstClosureParam;
            _lexicalScope = lexicalScope;
            _hiddenVariables = new AstParameters();
            _localsTuple = DefineHiddenVariable("#locals", MakeLocalsTupleType());
            _outermostClosureReferredTo = this;
        }
Exemplo n.º 51
0
        public LocalVariable(string name, LexicalScope parentScope, IChelaType type, bool pseudoLocal)
            : base(type, parentScope.GetModule())
        {
            base.SetName(name);
            this.parentScope = parentScope;

            // Add the variable into this.
            this.isPseudoLocal = pseudoLocal;
            this.index = parentScope.AddLocal(this);
            this.argumentIndex = -1;
            this.position = null;

            // Check for generated locals.
            if(name.StartsWith("._gsym"))
                localType = LocalType.Generated;
        }
Exemplo n.º 52
0
 private void CompileProgn(Cons formList, LexicalScope lexScope)
 {
     if(formList.Head != Cons.Nil)
       {
     while (formList.Tail != Cons.Nil)
     {
       CompileForm(formList.Head, lexScope);
       _gen.Emit(OpCodes.Pop);
       Assert.TypeIs(formList.Tail, typeof(Cons));
       formList = formList.Tail as Cons;
     }
     CompileForm(formList.Head, lexScope);
       }
       else
       {
     var fldInfo = typeof(Cons).GetField("Nil", BindingFlags.Public | BindingFlags.Static);
     _gen.Emit(OpCodes.Ldsfld, fldInfo);
       }
 }
Exemplo n.º 53
0
        private void CompileFuncall(Symbol fnSym, Cons paramList, LexicalScope lexScope)
        {
            if(lexScope.IsBound(fnSym, Symbol.FunctionSlot))
              {
            GenLexSymValue(lexScope, fnSym, Symbol.FunctionSlot);
              }
              else
              {
            FieldInfo functionSlotFld = typeof(Symbol).GetField("FunctionSlot");
            if(functionSlotFld == null)
            {
              throw new CompilerError("Unable to find VM.Types.Symbol.FunctionSlot field");
            }

            GenDynSymValue(fnSym, functionSlotFld);
              }

              MethodInfo invokeMethInfo = typeof(Function).GetMethod("Invoke");
              if(invokeMethInfo == null)
              {
            throw new CompilerError("Unable to find VM.Function.Invoke method");
              }

              var paramCount = ConsAux.Reduce(paramList, (x, counter) => counter + 1, 0);
              _gen.Emit(OpCodes.Newarr, paramCount);

              ConsAux.Reduce(paramList, (x, counter) =>
            {
              _gen.Emit(OpCodes.Dup);
              _gen.Emit(OpCodes.Ldc_I4, counter + 1);
              CompileForm(x, lexScope);
              _gen.Emit(OpCodes.Stelem_Ref);
              return counter + 1;
            }, 0);

              _gen.Emit(OpCodes.Call, invokeMethInfo);
        }
Exemplo n.º 54
0
        public void LeaveMethodDefinition() {
            Debug.Assert(_currentElement == _currentMethod);
            MethodScope oldMethod = _currentMethod;

            _currentElement = oldMethod.Parent;
            _currentRescue = oldMethod.ParentRescue;
            _currentLoop = oldMethod.ParentLoop;
            _currentBlock = oldMethod.ParentBlock;
            _currentVariableScope = oldMethod.ParentVariableScope;
            _currentMethod = oldMethod.ParentMethod;
        }
Exemplo n.º 55
0
 internal override Expression/*!*/ ToCondition(LexicalScope/*!*/ currentScope) {
     return new RegularExpressionCondition(this);
 }
Exemplo n.º 56
0
        public void EnterMethodDefinition(
            ScopeBuilder/*!*/ locals, 
            MSA.Expression/*!*/ selfParameter,
            MSA.ParameterExpression/*!*/ runtimeScopeVariable,
            MSA.Expression blockParameter,
            string/*!*/ methodName,
            Parameters parameters) {
            Assert.NotNull(locals, selfParameter, runtimeScopeVariable);

            MethodScope method = new MethodScope(
                locals,
                selfParameter, 
                runtimeScopeVariable, 
                blockParameter, 
                methodName, 
                parameters
            );

            method.Parent = _currentElement;
            method.ParentRescue = _currentRescue;
            method.ParentLoop = _currentLoop;
            method.ParentBlock = _currentBlock;
            method.ParentVariableScope = _currentVariableScope;
            method.ParentMethod = _currentMethod;

            _currentElement = method;
            _currentRescue = null;
            _currentLoop = null;
            _currentBlock = null;
            _currentVariableScope = method;
            _currentMethod = method;
        }
Exemplo n.º 57
0
        public void EnterModuleDefinition(
            ScopeBuilder/*!*/ locals,
            MSA.Expression/*!*/ selfVariable,
            MSA.ParameterExpression/*!*/ runtimeScopeVariable, 
            bool isSingleton) {
            Assert.NotNull(locals, selfVariable, runtimeScopeVariable);

            ModuleScope module = new ModuleScope(locals, selfVariable, runtimeScopeVariable, isSingleton);

            module.Parent = _currentElement;
            module.ParentVariableScope = _currentVariableScope;
            module.ParentModule = _currentModule;

            _currentElement = module;
            _currentVariableScope = module;
            _currentModule = module;
        }
Exemplo n.º 58
0
        public void LeaveModuleDefinition() {
            Debug.Assert(_currentElement == _currentModule);
            ModuleScope oldModule = _currentModule;

            _currentElement = oldModule.Parent;
            _currentVariableScope = oldModule.ParentVariableScope;
            _currentModule = oldModule.ParentModule;
        }
Exemplo n.º 59
0
 protected ModuleDefinition(LexicalScope/*!*/ definedScope, Body/*!*/ body, SourceSpan location)
     : base(definedScope, body, location) {
     _qualifiedName = null;
 }
Exemplo n.º 60
0
        public void LeaveSourceUnit() {
            Debug.Assert(_currentElement == _currentMethod && _currentVariableScope == _currentMethod);
            Debug.Assert(_currentLoop == null && _currentRescue == null);
            Debug.Assert(_currentBlock == null);

            _currentElement = null;
            _currentMethod = null;
            _currentVariableScope = null;
        }