Example #1
0
 public Function(Identifier returnType, Identifier name, Sequence<Parameter> pars, Sequence<Statement> stmts)
 {
     Type[] tar = Parameter.ConvertSequenceToTypeArray(pars);
     var mb = CodeGenerator.CreateFunction(name.Value, TypeChecker.ConvertStringToType(returnType.Value), tar);
     mi = mb;
     this.stmts = stmts;
     if (fns.ContainsKey(name.Value))
     {
         throw new Exception("Function redeclared. Note: overloaded functions are not supported at this time.");
     }
     fns.Add(name.Value, this);
     int count = 1; //parameters start at index 1 - 0 is the return. not sure on GetParameters() though - more testing is needed, but i don't think it includes the returntype as there is a separate way to get that
     foreach (Parameter p in pars)
     {
         mb.DefineParameter(count++, ParameterAttributes.None, p.Name);
     }
     ec = new ExecutionContext(null);
     ec.SetParameters(pars.ToArray());
 }
Example #2
0
 public Parameter(Identifier type, Identifier name)
 {
     this.type = TypeChecker.ConvertStringToType(type.Value);
     this.name = name.Value;
 }
Example #3
0
 public FunctionCall(Identifier funcName, Sequence<Expression> alist)
 {
     this.funcName = funcName.Value;
     this.alist = alist;
 }
Example #4
0
 public Function(Identifier returnType, Identifier name, Sequence<Statement> stmts)
     : this(returnType, name, new Sequence<Parameter>(), stmts)
 {
 }
Example #5
0
 public CallStatement(Identifier funcName)
 {
     this.fc = new FunctionCall(funcName, new Sequence<Expression>());
 }
Example #6
0
 public AssignmentStatement(Identifier varName, Expression e)
 {
     this.e = e;
     this.varName = varName.Value;
 }