Example #1
0
 public IsExpression(Source source, object obj,
     object type)
         : base(source)
 {
     this.obj = (Expression) obj;
     this.type = (Expression) type;
 }
Example #2
0
 public WhileStatement(Source source, object condition,
     object body)
         : base(source)
 {
     this.condition = (Expression) condition;
     this.body = (Statement) body;
 }
 public EqualityExpression(Source source, object a,
     object b)
         : base(source)
 {
     this.a = (Expression) a;
     this.b = (Expression) b;
 }
 public MultiplyExpression(Source source, object a,
     object b)
         : base(source)
 {
     this.a = (Expression) a;
     this.b = (Expression) b;
 }
 public GreaterOrEqualExpression(Source source,
     object a, object b)
         : base(source)
 {
     this.a = (Expression) a;
     this.b = (Expression) b;
 }
Example #6
0
 public DivideExpression(Source source, object a,
     object b)
         : base(source)
 {
     this.a = (Expression) a;
     this.b = (Expression) b;
 }
Example #7
0
 public NewExpression(Source source, object type,
     object parameters)
         : base(source)
 {
     this.type = (Expression) type;
     this.parameters = (List<object>) parameters;
 }
 public SubtractExpression(Source source, object a,
     object b)
         : base(source)
 {
     this.a = (Expression) a;
     this.b = (Expression) b;
 }
Example #9
0
 public MemberExpression(Source source, object obj,
     object member)
         : base(source)
 {
     this.obj = (Expression) obj;
     this.member = (Name) member;
 }
Example #10
0
 public CallExpression(Source source, object callable,
     object parameters)
         : base(source)
 {
     this.callable = (Expression) callable;
     this.parameters = (List<object>) parameters;
 }
Example #11
0
 public AssignExpression(Source source, object to,
     object from)
         : base(source)
 {
     this.from = (Expression) from;
     this.to = (Expression) to;
 }
 public SetPrecedenceStatement(Source source, object a,
     object relation, object b)
         : base(source)
 {
     this.a = (Expression) a;
     this.relation = (string) relation;
     this.b = (Expression) b;
 }
Example #13
0
 public IfStatement(Source source, object condition,
     object trueBody, object falseBody)
         : base(source)
 {
     this.condition = (Expression) condition;
     this.trueBody = (Statement) trueBody;
     this.falseBody = (Statement) falseBody;
 }
Example #14
0
 public TryStatement(Source source, object tryBody,
     object catchVariable, object catchBody)
         : base(source)
 {
     this.tryBody = (Statement) tryBody;
     this.catchVariable = (Expression) catchVariable;
     this.catchBody = (Statement) catchBody;
 }
Example #15
0
 public ClassStatement(Source source, object name, object baseType,
     object members)
         : base(source)
 {
     this.name = (Name) name;
     this.baseType = (Expression) baseType;
     this.members = (List<object>) members;
 }
Example #16
0
 public ThrowStatement(Source source, object exception)
     : base(source)
 {
     this.exception = (Expression) exception;
 }
 public ReferencePatternExpression(Source source, object name)
     : base(source)
 {
     this.name = (Expression) name;
 }
 public ExpressionStatement(Source source,
     object expression)
         : base(source)
 {
     this.expression = (Expression) expression;
 }
Example #19
0
 public NotExpression(Source source, object a)
     : base(source)
 {
     this.a = (Expression) a;
 }
Example #20
0
 public ParenExpression(Source source, object body)
     : base(source)
 {
     this.body = (Expression) body;
 }
Example #21
0
 public Option(Source source, object optionKey, object optionValue)
     : base(source)
 {
     this.optionKey = (Name) optionKey;
     this.optionValue = (Expression) optionValue;
 }
Example #22
0
        public void Define(RuntimeState state)
        {
            AbstractPattern basePattern;
            
            Type baseType;

            if (this.baseType != null)
            {
                baseType = (Type) this.baseType.Get(state);
                basePattern = (AbstractPattern) Pattern.PatternForType(baseType);
            }
            else
            {
                baseType = typeof(RuntimeObject);
                basePattern = null;
            }

            ClassBuilder classBuilder = new ClassBuilder(
                state.Runtime.CompilerModule,
                state.Scope.GetModule(),
                name.name,
                baseType);

            // Go through members
            
            if (members != null)
            {
                foreach (object member in members)
                    ((Member) member).Build(state, classBuilder);
            }
            
            UserDefinedNode userDefined = null;;
            
            if (classBuilder.Pattern == null)
            {
                bool parseMethod = false;;
                
                foreach (Method method in classBuilder.Methods)
                    if (method.Name == "Parse")
                    {
                        parseMethod = true;
                        break;
                    }
                
                if (parseMethod)
                {
                    userDefined = new UserDefinedNode(Source,
                        null);
                    
                    classBuilder.Pattern = new ConcretePattern(Source,
                        name.name, userDefined);
                }
                else
                    classBuilder.Pattern = new AbstractPattern(Source,
                        classBuilder.TypeBuilder.Name);
            }

            // Create the class, which closes the pattern, and define the pattern

            Type type = classBuilder.CreateType();
            state.Runtime.Grammar.PatternDefined(classBuilder.Pattern);

            state.Scope.SetName(name.name, type);
            
            if (userDefined != null)
                userDefined.Type = type;

            // Add a concrete class as an alt to its abstract

            if (basePattern != null)
            {
                basePattern.AddAltPattern(classBuilder.Pattern);
                basePattern.Updated();
            }
        }